/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package TagLibrary;

import java.util.Hashtable;
import java.util.Stack;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

public class PutTag extends TagSupport{
    private String name;
    private String content;
    private boolean direct;

    public void setName(String name) {
        this.name = name;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public void setDirect(boolean direct) {
        this.direct = direct;
    }

   
    @Override
    public int doStartTag() throws JspException {
       InsertTag parent= (InsertTag) this.getParent();
       Stack stack=parent.getStack();
       if(stack==null){
           throw new JspException("GetTag.doStartTag(): NO STACK");
       }
       Hashtable params=(Hashtable) stack.peek();
       if(params==null){
           throw new JspException("GetTag.doStartTag(): NO HASHTABLE");
       }
       params.put(name, new PageParameter(content, direct));
        return SKIP_BODY;
    }

    @Override
    public int doEndTag() throws JspException {
        return EVAL_PAGE;
    }

    @Override
    public void release() {
        this.content=null;
        this.name=null;
        this.direct=true;
    }
    
}
